package com.company;

import java.util.Scanner;

public class Yuekao1 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //判断是否结束
        String a = null;
        do {
            System.out.print("请输入第一个数：");
            double x1 = input.nextDouble();
            System.out.print("请输入第二个数：");
            double x2 = input.nextDouble();
            System.out.print("请输入运算符：");
            char op = input.next().charAt(0);
            if (op == '+') {
                System.out.print(x1);
                System.out.print(op);
                System.out.print(x2 + "=" + (x1 + x2));
            } else if (op == '-') {
                System.out.print(x1);
                System.out.print(op);
                System.out.print(x2 + "=" + (x1 - x2));
            } else if (op == '*') {
                System.out.print(x1);
                System.out.print(op);
                System.out.print(x2 + "=" + (x1 * x2));
            } else if (op == '/' && x2 != 0) {
                System.out.print(x1);
                System.out.print(op);
                System.out.print(x2 + "=" + (x1 / x2) + "\n");
            } else {
                System.out.print("除数不能为0！");
            }
            System.out.println();
            System.out.print("是否继续？Y:继续(不区分大小写),任意字符:结束");
            a = input.next();
        } while ("Y".equalsIgnoreCase(a));
    }
    //请编写一个Java程序，实现如下功能：
    // 从控制台接收命令三个参数x1、x2和op，其中x1和x2为double型数，
    // op是某个算数运算符（+、 —、*、/ 之一）,其中要考虑除数不能为零。
}

